def vcb_set_delivery_mode_auto(): 
  UCBServer.cfgApp.ChangeOption("UCBServer", "delivery_mode", "auto")
  
def vcb_set_delivery_mode_preview(): 
  UCBServer.cfgApp.ChangeOption("UCBServer", "delivery_mode", "preview")  
  

def vcb_set_auto_dial_mode_engaging(): 
  UCBServer.cfgApp.ChangeOption("UCBServer", "auto_dial_mode", "engaging")

def vcb_set_auto_dial_mode_dial_ahead(): 
  UCBServer.cfgApp.ChangeOption("UCBServer", "auto_dial_mode", "dial_ahead")

def vcb_set_callback_processed_true(): 
  UCBServer.cfgApp.ChangeOption("UCBServer", "callback_processed", "true")   
  
def vcb_set_callback_processed_false(): 
  UCBServer.cfgApp.ChangeOption("UCBServer", "callback_processed", "false")  
  
def remove_cpd_from_ucb_connections():
  if not UCBServer.useCPD:
    ProgrammWarning("No CPD is configured in UCBServer connections!!! Nothing will be removed")
  else:
    servers = UCBServer.cfgApp.GetServers()
    for server in servers:
      if server.type == CfgAppType.CFGSDialer.val:
        UCBServer.cfgApp.DeleteConnectionDBID(server.DBID)
        UCBServer.useCPD = False

def vcb_voice_asap_1():
  """Callback ASAP to Voice DN"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()    
    
    
def vcb_voice_asap_2():
  """Callback ASAP to Voice DN, reject callback, agent notready-ready, gets callback again"""
  if UCBServer.delivery_mode != "preview": return
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.RejectCallBack() 
    VCBAgent1.SetNotReady()
    VCBAgent1.SetReady()
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()
    
def vcb_voice_asap_3():
  """Two callbacks ASAP to Voice DN, second should be ignored as duplicated"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  Customer1.MakeCall(VCBEntryPoint1)  
  CD2 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP)  #error, duplicated call back
  Customer1.ReleaseCall()   
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()    
  
    
def vcb_busy_asap_1():
  """Callback ASAP to Busy DN"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(BusyCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack() 
    
def vcb_voice_scheduled_1():
  """Callback Scheduled to Voice DN"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()    
    
def vcb_voice_scheduled_2():
  """Callback Scheduled to Voice DN, agent is ready after time line for callback"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60)
  Customer1.ReleaseCall()  
  print "delay 150 sec before agent ready"
  time.sleep(150) #more than inMins  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()     
  
def vcb_voice_scheduled_3():
  """Callback Scheduled to Voice DN with time < current time"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = -2
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60) #time passed
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  
def vcb_voice_scheduled_4():
  """Two callbacks Scheduled to Voice DN, first should be replaced"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 4
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60)
  Customer1.ReleaseCall()  
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  CB2 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60) # replaces first
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB2:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack() #2
    VCBAgent1.ProcessCallBack()  
 
 
def vcb_voice_scheduled_5():
  """Two callbacks to Voice DN, first Scheduled, second ASAP, second should be ignored"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  timeToCall = time.time() + inMins*60
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
  Customer1.ReleaseCall()  
  Customer1.MakeCall(VCBEntryPoint1)
  CB2 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP) # error, should be ignored
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack() #1
    VCBAgent1.ProcessCallBack()  

def vcb_voice_scheduled_6():
  """Two callbacks to Voice DN, first ASAP, second Scheduled, first should be replaced"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP) 
  Customer1.ReleaseCall()  
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  timeToCall = time.time() + inMins*60
  CB2 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)# should replace asap
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB2:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack() #2
    VCBAgent1.ProcessCallBack() 
  
 
def vcb_busy_scheduled_1():
  """Callback Scheduled to Busy DN"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  CB1 = Customer1.RequestVoiceCallBack(BusyCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack() 
  
   
  
def vcb_mixed_1():
  """Two callbacks, first Scheduled to Busy DN, second ASAP to Voice DN"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  CB1 = Customer1.RequestVoiceCallBack(BusyCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60)
  Customer1.ReleaseCall()  
  Customer1.MakeCall(VCBEntryPoint1)
  CB2 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB2:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack() #to voice
    VCBAgent1.ProcessCallBack()  
    VCBAgent1.SetNotReady()
    VCBAgent1.SetReady()  
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack() # to busy
    VCBAgent1.ProcessCallBack()  
  
#-------------------------------------------------------------- 

      

def vcb_voice_asap_cancel_1():
  """Callback ASAP to Voice DN, callback cancel"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.CancelCallBack()   
  
def vcb_busy_asap_cancel_1():
  """Callback ASAP to Busy DN, callback cancel, no treatments"""
  if UCBServer.delivery_mode != "preview": return
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(BusyCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.CancelCallBack()   
  


def vcb_voice_scheduled_cancel_1():
  """Callback Scheduled to Voice DN, callback cancel"""
  if UCBServer.delivery_mode != "preview": return
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.CancelCallBack()   
  
def vcb_busy_scheduled_cancel_1():
  """Callback Scheduled to Busy DN, callback cancel, no treatments"""
  if UCBServer.delivery_mode != "preview": return
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  CB1 = Customer1.RequestVoiceCallBack(BusyCallBackDN, type = VCBType.Scheduled, timeToCall = time.time() + inMins*60)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.CancelCallBack()   
  

  
#Time zones
#Restriction: calls only to TZ which have Day Light Savings, no calls 

    
def vcb_voice_scheduled_tz_1():
  """Callback Scheduled to Voice DN, time zone CST"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  tzDif = 2
  timeZone = "CST"
  timeToCall = time.time() + inMins*60 + tzDif*60*60 #+2 hours
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall, timeZone = timeZone)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()      
    
    
 

def vcb_voice_scheduled_tz_2():
  """Callback Scheduled to Voice DN, time zone ECT"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  timeZone = "ECT" 
  tzDif = 9
  timeToCall = time.time() + inMins*60 + tzDif*60*60 
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall, timeZone = timeZone)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()   
    
def vcb_voice_scheduled_tz_3():
  """Callback Scheduled to Voice DN, time zone CST, time already expired"""
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = -125
  tzDif = 2
  timeZone = "CST"
  timeToCall = time.time() + inMins*60 + tzDif*60*60 #+2 hours
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall, timeZone = timeZone)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()   
  
    
#Business Days
def vcb_voice_auto_scheduled_bd_1():
  """Auto mode, callback Scheduled to Voice DN, on Sunday"""
  if sys.version[0:3] != '2.3': Skip0("Test case is supported in Python 2.3 only")
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  f = "%m %d %Y %H %M"
  t = "10 15 2005 09 00" #15 Oct 2005 - sunday
  timeToCall = time.mktime(time.strptime(t, f))
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  UCBServer.SetTestResult(TestResEnum.ForceReset) # too long to wait for call back if business days are not configured
    
def vcb_voice_auto_scheduled_bd_2():
  """Auto mode, callback Scheduled to Voice DN, working day after 5 pm"""
  if sys.version[0:3] != '2.3': Skip0("Test case is supported in Python 2.3 only")
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  f = "%m %d %Y %H %M"
  t = "10 11 2005 19 00" #11 Oct 2005, after 5 pm
  timeToCall = time.mktime(time.strptime(t, f))
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  UCBServer.SetTestResult(TestResEnum.ForceReset) # too long to wait for call back if business days are not configured
    
def vcb_voice_auto_scheduled_bd_3():
  """Auto mode, callback Scheduled to Voice DN, Christmas holiday must be configured"""
  if sys.version[0:3] != '2.3': Skip0("Test case is supported in Python 2.3 only")
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  f = "%m %d %Y %H %M"
  t = "12 25 2005 10 00" #25 dec 2005
  timeToCall = time.mktime(time.strptime(t, f))
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  UCBServer.SetTestResult(TestResEnum.ForceReset) # too long to wait for call back if business days are not configured

    
def vcb_voice_auto_scheduled_bd_4():
  """Auto mode, callback Scheduled to Voice DN, Christmas holiday and overtime (17 - 20) must be configured"""
  if sys.version[0:3] != '2.3': Skip0("Test case is supported in Python 2.3 only")
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  f = "%m %d %Y %H %M"
  t = "12 25 2005 18 30" #25 dec 2005, 18:30
  timeToCall = time.mktime(time.strptime(t, f))
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  UCBServer.SetTestResult(TestResEnum.ForceReset) # too long to wait for call back if business days are not configured
    
#Black List    
def vcb_black_list_1():
  BlackCallBackDN = VoiceCallBackDN.tserver.DN("12345678", answerType = "Busy", tserver = VoiceCallBackDN.tserver)
  UCBServer.AddPhoneToBlackList(BlackCallBackDN.number)
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(BlackCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1: 
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()   
  UCBServer.RemovePhoneFromBlackList(BlackCallBackDN.number)

  
def vcb_black_list_2():
  BlackCallBackDN = VoiceCallBackDN.tserver.DN("12345678", answerType = "Busy", tserver = VoiceCallBackDN.tserver)
  UCBServer.AddPhoneToBlackList("123%")
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(BlackCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()  
  if CB1:
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()     
  UCBServer.RemovePhoneFromBlackList("123%")
  
def vcb_black_list_3():
  BlackCallBackDN = VoiceCallBackDN.tserver.DN("12345678", answerType = "Busy", tserver = VoiceCallBackDN.tserver)
  UCBServer.AddPhoneToBlackList("12__5678")
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(BlackCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()  
  if CB1: 
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()     
  UCBServer.RemovePhoneFromBlackList("12__5678")  
  
#def vcb_black_list_4():
#  BlackCallBackDN = VoiceCallBackDN.tserver.DN("12345678", answerType = "Busy", tserver = VoiceCallBackDN.tserver)
#  UCBServer.RemoveTreatments()
##  VCBAgent1.SetNotReady()
#  Customer1.MakeCall(VCBEntryPoint1)
#  inMins = 3
#  timeToCall = time.time() + inMins*60
#  CB1 = Customer1.RequestVoiceCallBack(BlackCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
#  Customer1.ReleaseCall()  
#  UCBServer.AddPhoneToBlackList(BlackCallBackDN.number)  
#  VCBAgent1.SetReady()
#  if CB1: 
#    VCBAgent1.PreviewCallBack()
#    VCBAgent1.CallBack()
#    VCBAgent1.ProcessCallBack()   
#  UCBServer.RemovePhoneFromBlackList(BlackCallBackDN.number)  
#  
#def vcb_black_list_5():
#  BlackCallBackDN = VoiceCallBackDN.tserver.DN("12345678", answerType = "Busy", tserver = VoiceCallBackDN.tserver)
#  UCBServer.RemoveTreatments()
##  VCBAgent1.SetNotReady()
#  Customer1.MakeCall(VCBEntryPoint1)
#  inMins = 3
#  timeToCall = time.time() + inMins*60
#  CB1 = Customer1.RequestVoiceCallBack(BlackCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
#  Customer1.ReleaseCall()  
#  UCBServer.AddPhoneToBlackList(BlackCallBackDN.number)  
#  VCBAgent1.SetReady()
#  if CB1: 
#    VCBAgent1.PreviewCallBack()
#    VCBAgent1.CallBack()
#    VCBAgent1.ProcessCallBack()   
#  UCBServer.RemovePhoneFromBlackList(BlackCallBackDN.number)    

def vcb_to_default_1():
  UCBServer.cfgApp.ChangeOption("UCBServer", "default_routing_timeout", "40") 
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  inMins = 3
  timeToCall = time.time() + inMins*60
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.Scheduled, timeToCall = timeToCall)
  Customer1.ReleaseCall() 
  ScsRouter.Stop()
  try:
    if CB1: 
      VCBDefaultAgent.SetReady()
      VCBDefaultAgent.PreviewCallBack()
      VCBDefaultAgent.CallBack()
      VCBDefaultAgent.ProcessCallBack() 
  finally:
    UCBServer.cfgApp.ChangeOption("UCBServer", "default_routing_timeout", "0") 
    ScsRouter.Start()
    
  VCBAgent1.SetReady()  
  
def vcb_voice_asap_no_preview_acknoledge_1():
  """Callback ASAP to Voice DN, reject callback, agent notready-ready, gets callback again"""
  if UCBServer.delivery_mode != "preview": return
  UCBServer.RemoveTreatments()
  VCBAgent1.SetNotReady()
  Customer1.MakeCall(VCBEntryPoint1)
  CB1 = Customer1.RequestVoiceCallBack(VoiceCallBackDN, type = VCBType.ASAP)
  Customer1.ReleaseCall()  
  VCBAgent1.SetReady()
  if CB1:
    VCBAgent1.PreviewCallBack(acknowledge = 0)
    VCBAgent1.SetNotReady()
    VCBAgent1.SetReady()
    VCBAgent1.PreviewCallBack()
    VCBAgent1.CallBack()
    VCBAgent1.ProcessCallBack()

